package com.starblink.feedback.ui

import android.view.View
import androidx.core.os.bundleOf
import androidx.fragment.app.setFragmentResult
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.starblink.android.basic.ext.click
import com.starblink.android.basic.ext.toast
import com.starblink.android.basic.network.base.SkGqlClient
import com.starblink.android.basic.widget.ConfirmDialog
import com.starblink.android.basic.widget.dialog.BaseBottomSheetFragment
import com.starblink.basic.route.RoutePage
import com.starblink.basic.style.R
import com.starblink.feedback.databinding.DialogPersonalHomeObjectiveMoreBinding
import com.starblink.rocketreserver.BlockAccountMutation
import com.starblink.rocketreserver.fragment.AccountF
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch

/**
 * 个人首页-客态-更多弹窗
 */
@Route(path = RoutePage.DialogFragment.PERSONAL_HOME_OBJECTIVE_MORE_DIALOG)
class PersonalHomeObjectiveMoreDialog() : BaseBottomSheetFragment() {
    lateinit var viewBinding: DialogPersonalHomeObjectiveMoreBinding

    companion object {
        const val RESULT_CLICK_BLOCK = "RESULT_CLICK_BLOCK"
        const val ARG_RESULT = "ARG_RESULT"
    }

    @Autowired(name = RoutePage.ARG.USER_INFO)
    @JvmField
    var objectiveUserInfo: AccountF? = null

    override fun getBindingRootView(): View {
        viewBinding = DialogPersonalHomeObjectiveMoreBinding.inflate(layoutInflater)
        return viewBinding.root
    }

    override fun initView() {
        viewBinding.close.click {
            dismiss()
        }

        viewBinding.feedback.click {
            val dialogFeedback =
                PostFeedbackDialog(
                    requireActivity(),
                    com.starblink.android.basic.R.style.dialog_center
                )
            dialogFeedback.setId("0")
            dialogFeedback.show()
            dismiss()
        }

        viewBinding.report.click {
            objectiveUserInfo?.let {
                ReportPostDialog(
                    contxt = requireActivity(),
                    targetId = it.id,
                    reportType = 5,
                ).show(requireActivity().supportFragmentManager, "report")
            }

            dismiss()
        }

        viewBinding.btnBlock.click {
            setFragmentResult(
                RESULT_CLICK_BLOCK,
                bundleOf(ARG_RESULT to true)
            )
            dismiss()
        }
    }


}